$(function() {
        	var now = new Date();
        	var opt = {
        		yearSuffix: '年',
        		monthSuffix: '月',
        		daySuffix: '日',
        		theme: 'auto',
        		lang: 'zh',
        		display: 'inline',
        		rows: 3,
        		max: new Date(now.getFullYear() + 100, now.getMonth(), now.getDate())
        	};

        	function getDayAfterMonth(dt){
    			var year = dt.getFullYear() ,month = dt.getMonth(), date = dt.getDate();
    			var result = new Date();
    			if(month==11){
    				result.setYear(year+1);
    				result.setMonth(0);
    			}else{
    				result.setYear(year);
    				result.setMonth(month+1);
    			}
    			result.setDate(date);
        		return result;
        	}

        	var dateBegin = mobiscroll.date('#date-begin', $.extend({
        		defaultValue: new Date(),
        		onChange: function(event, inst){
        			$('.longTime').removeProp('checked').trigger('change');
        			changeClass()
        			dateEnd.setVal(getDayAfterMonth(inst.getVal(true)));
        		}
        	},opt));

        	var dateEnd = mobiscroll.date('#date-end', $.extend({
        		onChange: function(event, inst){
        			$('.longTime').removeProp('checked').trigger('change');
        			changeClass()
        		}
        	},opt));

        	dateEnd.setVal(getDayAfterMonth(now));

        	$('.longTime').on('change', function() {
        		var opt = {
        			readonly: $(this).prop('checked')
        		}
        		if (opt.readonly) {
        			$('.date').addClass('disabled');
        			$('.seleBtn').removeClass('unselected').addClass('selected');
        		} else {
        			$('.date').removeClass('disabled');
        			$('.seleBtn').removeClass('selected').addClass('unselected');
        		}
        	});
			function changeClass(){
				if($('.longTime').is(':checked')){
					$('.seleBtn').removeClass('selected').addClass('unselected');
				}else{
					$('.seleBtn').removeClass('unselected').addClass('selected');
				}
			}
        });